'use strict';

/* EditTree Controllers */
app.controller('featureCtrl', ['$scope', '$modal', '$http', '$stateParams', '$rootScope', '$filter', '$location', '$timeout', 'lodash', function($scope, $modal, $http, $stateParams, $rootScope, $filter, $location, $timeout, lodash) {
    $rootScope.initBreadcrumb($scope.breadcrumb);
    //页面加载时，给headerElement设置元素
    $rootScope.initHeaderElements($scope.settings);
    var refresh = {
        show : true,
        label: "刷新",
        func : function() {
            $scope.$broadcast('reloadGetFeatures', '');
        }
    };
    var backUrl = {
        show : true,
        label: "返回",
        func : function() {
            $scope.buttonsClick("cancel");
        }
    };
    var backFeature = {
        show : true,
        label: "返回功能点",
        func : function() {
            $scope.info.sltItemId = "";
            $scope.info.showMap = true;
        }
    };
    var jumpUrl = {
        show: true,
        label: "功能点架构",
        func: function () {
            window.open('#/app/repository/featureMap/-1');
        }
    };
    $scope.reqDetails = {};
    var url = matrix_product_url +"/brdRequirement/getBrdRequirements?reqId="+ $stateParams.reqId;
    $http.get(url).success(function(result) {
        if(result.code == "0") {
            if(result.data) {
                $scope.reqDetails = result.data[0];
                $scope.breadcrumb.push('产品设计',$scope.reqDetails.reqName);
            }
        }
    });

    $scope.settings.btnEle.push(refresh);
    $scope.settings.btnEle.push(backUrl);
    $scope.settings.btnEle.push(backFeature);
    if($rootScope.isMatrixCusRole('matrix_sys_admin')){
        $scope.settings.btnEle.push(jumpUrl);
    }
    //结束headerElement设置
    
    setFlowHeight();

    function setFlowHeight() {
        $timeout(function() {
            var h = document.documentElement.clientHeight || document.body.clientHeight;
            h = h - 200;
            $(".master-content").css({
                "max-height": h +"px",
                "overflow": "auto",
            });
        }, 500)
    }
    
    $(window).resize(function() {
        setFlowHeight();
    });

    //init
    $scope.info = {
        sltItemId : "",
        showMap   : true,
        branch    : {},
        reqId     : "",
        reqName   : $stateParams.reqName,
        featureId : "",
        sys       : "",
        mapDatas  : [],
        reloadTree: true,
        relateList: [],
        showPanel : "true"
    };
    $scope.info.diagramScope = {};
    $scope.info.selectInfo = {}
    $scope.info.meneList = [];
    $scope.info.pageList = [];
    $scope.info.featureList = [];
    $scope.info.mapDatas = [];
    $scope.info.search = ""
    $scope.info.showName = "map";
    // $scope.LegendSys = config_flow_legend_sys;
    $scope.info.sys = {"crtname": "请选择系统"};

    switchData();
    getRelateList();

    // 点击关联列表中的数据
    $scope.clickRelateItem = function(feature) {
        $scope.info.showMap = false;
        $scope.info.sltItemId = feature.id;
        $scope.info.reqId = $stateParams.reqId || "-1";
        $scope.info.featureId = feature.id;
        $scope.info.sys = feature.sys;
        $scope.info.branch = feature;
        if(feature.type == "PROTOTYPE") {
            $scope.info.showPanel = "false";
        } else {
            $scope.info.showPanel = "true";
        }
    }

    // 获取关联数据
    function getRelateList() {
        var url = matrix_product_url + "/feature/getAllFeatureForReq?reqId="+ $stateParams.reqId +"&withAttr=0";
        $http.get(url).success(function(result) {
            if(result.code == "0") {
                $scope.info.relateList = result.data;
                $scope.info.relateItemList = result.data;
            } else {
                $rootScope.toasterErrorInfo(result.desc);
            }
        });
    }

    //选择产品事件
    $scope.selectLegendSysItem = function (item) {
        $scope.info.sys = item;
        switchData();
    }

    function switchData() {
        if (!$scope.info.sys.value) {
            return;
        }
        $scope.info.selectInfo = {}
        var list = []
        var url = matrix_product_url + "/feature/getAllElements?sys=" + $scope.info.sys.value;
        $rootScope.showPanelLoading();
        $http.get(url).success(function(result) {
            if (result.code == 0) {
                angular.forEach(result.data.menus, function (menu) {
                    menu = initMenu(menu)
                    list.push(menu)
                })
                angular.forEach(result.data.pages, function (page) {
                    page = initPage(page)
                    page.sys = $scope.info.sys.value;
                    list.push(page)
                })
                angular.forEach(result.data.features, function (feature) {
                    feature = initFeature(feature)
                    list.push(feature)
                })
                console.log("数据初始化成功");
                $scope.info.mapDatas = list;
                // $rootScope.$apply();
            } else {
                $rootScope.toasterErrorInfo(result.desc);
            }
            $rootScope.hidePanelLoading();
        });
    }

    //初始化菜单数据
    function initMenu(menu) {
        menu.key = menu.id;
        menu.parent = menu.parent_id;
        menu.name = menu.menu_name;
        menu.mapType = "MENU"
        if (menu.level == 0) {
            menu.mapType = "SYS"
        }
        menu.isRelate = null;
        return menu;
    }

    //初始化Page数据
    function initPage(page) {
        page.key = page.id;
        page.parent = page.menuId;
        page.name = page.title;
        page.mapType = "PAGE"
        page.isRelate = null;
        return page;
    }

    //初始化feature数据
    function initFeature(feature) {
        feature.key = feature.id
        feature.parent = feature.parent_id
        feature.name = feature.featureName;
        feature.mapType = feature.type == 'PROTOTYPE' ? "PROTOTYPE" : "FEATURE";
        feature.isRelate = lodash.findWhere($scope.info.relateList, {id: feature.id})?"red":null;
        return feature;
    }

    $scope.info.treeBackUrl = getStorage('treeBackUrl', $location.url());

    //声明方法，供mFunTree调用
    $scope.$on('updateFeature', function(event, data){
        updateFeature();
    });
    
    //调用winitFeaturePanel.js中的声明方法
    function updateFeature() {
        $scope.$broadcast('editFeature', '');
    };

    //声明方法(winitFeaturePanel调用)
    $scope.$on("getFeaturesByReq", function(event, data) {
        getFeaturesByReqId();
    });
    
    //调用mFunTree中的方法
    function getFeaturesByReqId() {
        $scope.$broadcast('getFeaturesByReqId', '');
    };
    
    function reload() {
        $scope.$broadcast('reloadGetFeatures', '');   //引用的是mFunTree.js中的声明
    }

    $scope.$on('reload', function(event, data){
        reload();
    });

    $scope.buttonsClick = function (type) {
      if (type == 'cancel') {
        $rootScope.backHistory();
      }
    }

    //获取点击的节点数据
    $scope.onSelect = function(selectedBranch) {
        $scope.info.showMap   = selectedBranch.parentId == "0" ? true : false;
        $scope.info.branch    = selectedBranch; 
        $scope.info.reqId     = selectedBranch.reqId ? selectedBranch.reqId : null;
        $scope.info.featureId = selectedBranch.id;
        $scope.info.sys       = selectedBranch.sys;
        if(selectedBranch.nodeType == undefined) {
            if(selectedBranch.type == "PROTOTYPE") {
                $scope.info.showPanel = "false";
            } else {
                $scope.info.showPanel = "true";
            }
        } else {
            if(selectedBranch.type == "PROTOTYPE") { 
                $scope.info.showPanel = "false";
             } else {
                $scope.info.showPanel = "true";
            }
        }
    }

    //解除功能点
    $scope.contactRelieve=function(info){
        var info = {};
        info.titleData = "提示";
        info.bodyData = "确定要解除关联吗？";
        $rootScope.confirmWindow(info, function (data) {
            if (data) {
                $http.get(matrix_product_url + '/brdRequirement/getBrdRequirements?reqId='+$stateParams.reqId).success(function(reqData){
                    if(reqData.code==0){
                        $scope.info.reqInfo=reqData.data[0];
                    }
                    delete($scope.info.reqInfo.featureNodes[info.key])
                    $scope.contactRelieveSave();
                })
            }
        });
    }
    
    $scope.contactRelieveSave=function(){
         $.ajax({
            type: 'post',
            url: matrix_product_url + '/brdRequirement/saveBrdRequirement',
            data: JSON.stringify($scope.info.reqInfo),
            contentType: "application/json; charset=utf-8",
            success: function(data) {
                if (data.code == "0") {
                    if($scope.info.branch.selected == true){
                        $scope.info.branch.attrs.status = "ONLINE";
                        $scope.info.branch.attrs.reqId = "-1";
                        $scope.$apply();
                    }
                    resetFeatureInfo($scope.info.featureId,$scope.info.reqInfo.reqId);
                } else {
                    $rootScope.showMessage('error', '失败！', data.desc);
                }
            },
            error: function(data) {
                $rootScope.showMessage('error', '失败！', data.desc);
            }
        })
    }

    function resetFeatureInfo(featureId,reqId) {
         $.ajax({
            type: 'post',
            url: matrix_product_url + '/feature/dissociateRelation',
            data: {featureId: featureId,reqId:reqId},
            success: function(data) {
                if (data.code == "0") {
                    $rootScope.showMessage('success', '成功！', '解除并重置成功！');
                    $scope.info.branch.attrs.status = "ONLINE";
                    $scope.info.branch.attrs.reqId = "-1";
                    $scope.$broadcast('reloadFetureTree', '');
                } else {
                    $rootScope.showMessage('error', '失败！', data.desc);
                }
            },
            error: function(data) {
                $rootScope.showMessage('error', '失败！', data.desc);
            }
        })
    }

    //点击图例事件
    $scope.selectMap = function (info) {
        console.log(info);
        $scope.info.selectInfo = info;
        $scope.$apply();
    }

    //创建menu
    $scope.addMenu = function () {
        menuModal("add");
    };

    function menuModal(type) {
        var modalInstance = $modal.open({
            animation: true,
            templateUrl: getTemplateUrl("matrix/component/tpl/menuModal.html"),
            controller: "addMapMenuCtrl",
            keyboard: true,
            backdrop: true,
            resolve: {
                status: function () {
                    return type == 'add' ? true : false;
                },
                isFlowTree: function () {
                    return false;
                },
                menu: function () {
                    return $scope.info.selectInfo;
                },
                type: function () {
                    return type;
                }
            }
        });

        //点击modal新增后，把值传过来
        modalInstance.result.then(
            function (menu) {
                createMenu(menu)
            }, function (reason) {
                cancelModal(reason);
            });
    };

    //取消
    function cancelModal() {
        console.log("cancelModal");
    };

    //创建menu节点
    function createMenu(data) {
        var url = matrix_product_url + "/menu/save";
        var postParams = {
            "is_del": $scope.info.selectInfo.is_del,
            "level": data.status ? parseInt($scope.info.selectInfo.level) + 1 : parseInt($scope.info.selectInfo.level),
            "status": data.status ? "ADD" : "UPDATE",
            "req_id": $scope.info.selectInfo.req_id,
            "sys": $scope.info.selectInfo.sys,
            "parent_id": data.parent,
            "menu_name": data.name,
            "menu_data": {
                "name": data.name,
                "path": data.path,
                //"routeId" : path + "/" + menu.path
                "routeId": $scope.info.selectInfo.menu_data.routeId
            }
        };
        data.status ? postParams : postParams.id = $scope.info.selectInfo.id;
        $http({
            method: "post",
            url: url,
            data: JSON.stringify(postParams),
            headers: {"Content-Type": "application/json"}
        }).success(function (result) {
            if (result.code == "0") {
                if (!result.data) {
                    $rootScope.toasterErrorInfo("创建流程，返回数据错误！");
                }
                if (data.status) {
                    $scope.addNodeToTree(initMenu(result.data));
                } else {
                    if (data.operationType == "move") {
                        $scope.info.diagramScope.moveNode(data);
                    } else {
                        $scope.info.selectInfo.name = postParams.menu_name;
                        $scope.info.diagramScope.updateNode();
                    }
                }

                $rootScope.toasterSuccessInfo(data.status ? "创建成功！" : "修改成功！");
            } else {
                $rootScope.toasterErrorInfo(result.desc);
            }
        });
    };

    // 创建page
    $scope.addPage = function () {
        pageModal($scope.info.selectInfo, 'add');
    }

    function pageModal(selectedBranch, type) {
        var modalInstance = $modal.open({
            animation: true,
            templateUrl: getTemplateUrl("matrix/component/tpl/pageModal.html"),
            controller: "addMapPageModalCtrl",
            keyboard: true,
            backdrop: true,
            resolve: {
                branch: function () {
                    return selectedBranch;
                },
                status: function () {
                    return type == 'add' ? true : false;
                }
            }
        });

        //点击modal新增后，把值传过来
        modalInstance.result.then(
            function (page) {
                createPageModal(page);
            },
            function (reason) {
                cancelModal(reason);
            }
        );
    };

    //modal按钮新增----page
    function createPageModal(page) {
        var pageId = page.status ? "" : $scope.info.selectInfo.id;
        var postParams = {
            "id": pageId,
            "title": page.name,
            "fileName": page.status ? "" : page.fileName,
            "models": "",
            "menuId": page.pageMenuId,
            "menuPath": page.routeId,
        };
        var url = matrix_product_url + "/page/savePage";
        $http({
            method: "post",
            url: url,
            data: JSON.stringify(postParams),
            headers: {"Content-Type": "application/json"}
        }).success(function (result) {
            if (result.code == "0") {
                if (page.status) {
                    $scope.addNodeToTree(initPage(result.data));
                    $http.get(matrix_product_url + "/feature/getPageFeatures?pageId=" + result.data.id).success(function (featureData) {
                        if (featureData.code == "0") {
                            featureData.data[0].parent_id = featureData.data[0].pageId;
                            var feature = initFeature(featureData.data[0]);
                            $scope.addNodeToTree(feature);
                        }
                    })
                } else {
                    if (page.operationType == "move") {
                        $scope.info.diagramScope.moveNode(page);
                    } else {
                        $scope.info.selectInfo.name = postParams.title;
                        $scope.info.diagramScope.updateNode();
                    }
                }
                $rootScope.showMessage("success", "成功", (page.status ? "创建成功！" : "修改成功！"));
            } else {
                $rootScope.showMessage("error", "失败", result.desc);
            }
        });
    };

    $scope.addNodeToTree = function (data) {
        if(data.mapType == "FEATURE") {
            data.isRelate = "red";
        }
        $scope.info.diagramScope.createNode(data);
    }

    // 添加功能点
    $scope.addFeature = function (type) {
        var modalInstance = $modal.open({
            animation: true,
            templateUrl: getTemplateUrl("matrix/component/tpl/featureModal.html"),
            controller: "addFeatureMapCtrl",
            keyboard: true,
            backdrop: true,
            resolve: {
                branch: function () {
                    return $scope.info.selectInfo;
                },
                status: function () {
                    return type == 'add' ? true : false;
                }
            }
        });

        //点击modal新增后，把feature值传过来
        modalInstance.result.then(function (feature) {
            createFeature(feature);
        }, function (reason) {
            cancelModal(reason);
        });
    };

    // 创建功能点（新增）
    function createFeature(feature) {
        var postParams = {
            "sys": $scope.info.selectInfo ? ($scope.info.selectInfo.sys || "") : "",
            "path": feature.path,
            "reqId": "-1",
            "pageId": $scope.info.selectInfo.key,
            "originalPageId": $scope.info.selectInfo.key,
            "featureName": feature.name,
            "featureKind": feature.featureKind,
            "attr": {
                "feature_name": feature.name
            }
        };
        feature.status ? postParams : postParams.id = $scope.info.selectInfo.id;
        var url = matrix_product_url + "/feature/createFeature";
        $http({
            method: "post",
            url: url,
            data: JSON.stringify(postParams),
            headers: {"Content-Type": "application/json"}
        }).success(function (result) {
            if (result.code == "0") {
                if (feature.status) {
                    feature.id = result.data || "";

                    var relateItem = angular.copy(feature);
                    relateItem.id = result.data || "";
                    relateItem.sys = $scope.info.selectInfo ? ($scope.info.selectInfo.sys || "") : "";
                    relateItem.featureName = feature.name;
                    relateItem.status = "ADD";
                    $scope.info.relateItemList.push(relateItem);

                    var url = matrix_product_url + "/feature/featureOccupy?reqId="+ $stateParams.reqId +"&id="+ result.data;
                    $scope.info.reloadTree = false;
                    $http.get(url).success(function(result) {
                        $scope.info.reloadTree = true;
                        if(result.code == "0") {
                            feature.sys = $scope.info.selectInfo ? ($scope.info.selectInfo.sys || "") : "";
                            $scope.info.diagramScope.updateNode(true, feature);
                        } else {
                            $rootScope.toasterErrorInfo(result.desc);
                        }
                    })
                    $http.get(matrix_product_url + "/feature/getFeature?id=" + result.data + "&withPrototype=1&withAttr=0").success(function (featureData) {
                        if (featureData.code == "0") {
                            $scope.addNodeToTree(initFeature(featureData.data[0]))
                        }
                    })
                    // $scope.addNodeToTree(initFeature(result.data));
                } else {
                    if (feature.operationType == "move") {
                        $scope.info.diagramScope.moveNode(feature);
                    } else {
                        $scope.info.selectInfo.name = postParams.featureName;
                        $scope.info.diagramScope.updateNode();
                    }

                }
                $rootScope.toasterSuccessInfo(feature.status ? "创建成功！" : "修改成功！");
            } else {
                $rootScope.toasterErrorInfo(result.desc);
            }
        })
    };

    // 删除方法
    $scope.delete = function () {
        switch ($scope.info.selectInfo.mapType) {
            case "MENU":
                deleteMenu();
                break;
            case "PAGE":
                deletePage();
                break;
            case "FEATURE":
                deleteFeature();
                break;
        }
    }

    // 删除menu
    function deleteMenu() {
        var confirmParams = {
            "titleData": "提示",
            "bodyData": "确定要删除MENU【" + $scope.info.selectInfo.name + "】节点吗？"
        };
        $rootScope.confirmWindow(confirmParams, function (data) {
            if (data) {
                var deleteId = $scope.info.selectInfo.id;
                if (!deleteId) {
                    $rootScope.showMessage("error", "失败", "menuId未定义！");
                }
                var postParams = {
                    "id": deleteId,
                    "status": "DELETE"
                };
                var url = matrix_product_url + "/menu/save";
                $http({
                    method: "post",
                    url: url,
                    data: JSON.stringify(postParams),
                    headers: {"Content-Type": "application/json"}
                }).success(function (result) {
                    if (result.code == "0") {
                        $scope.info.diagramScope.deleteNode(initMenu([data], [])[0]);
                        $rootScope.showMessage("success", "成功", "menu节点删除成功！");
                    } else {
                        $rootScope.showMessage("error", "失败", result.desc);
                    }
                })
            }
        })
    }

    // 删除page
    function deletePage() {
        var confirmParams = {
            "titleData": "提示",
            "bodyData": "确定要删除PAGE【" + $scope.info.selectInfo.name + "】节点吗？"
        };
        $rootScope.confirmWindow(confirmParams, function (data) {
            if (data) {
                var deleteId = $scope.info.selectInfo.id;
                if (!deleteId) {
                    $rootScope.showMessage("error", "失败", "pageId未定义！");
                }
                var url = matrix_product_url + "/page/deletePage?pageId=" + deleteId;
                $http.get(url).success(function (result) {
                    if (result.code == "0") {
                        $scope.info.diagramScope.deleteNode(initPage([data], [])[0]);
                        $rootScope.showMessage("success", "成功", "page节点删除成功！");
                    } else {
                        $rootScope.showMessage("error", "失败", result.desc);
                    }
                });
            }
        });
    };

    // 删除feature
    function deleteFeature() {
        var confirmParams = {
            "titleData": "提示",
            "bodyData": "确定要删除FEATURE【" + $scope.info.selectInfo.name + "】功能点吗？"
        };
        $rootScope.confirmWindow(confirmParams, function (data) {
            if (data) {
                var url = matrix_product_url + "/feature/deleteFeature?featureId=" + $scope.info.selectInfo.id;
                $http.get(url).success(function (result) {
                    if (result.code == "0") {
                        $scope.info.diagramScope.deleteNode(initFeature([data], [])[0]);
                        $rootScope.showMessage("success", "成功", "删除成功！");
                    } else {
                        $rootScope.showMessage("error", "失败", result.desc);
                    }
                });
            }
        })
    };

    // 拉分支
    $scope.relate = function(info) {
        if(!$scope.info.selectInfo.id) {
            $rootScope.toasterErrorInfo("id不能为空！");
            return false;
        }
        var url = matrix_product_url + "/feature/featureOccupy?reqId="+ $stateParams.reqId +"&id="+ $scope.info.selectInfo.id;
        $http.get(url).success(function(result) {
            if(result.code == "0") {
                $scope.info.relateItemList.push($scope.info.selectInfo);
                if($scope.info.selectInfo) {
                    if($scope.info.selectInfo.type == "PROTOTYPE") {
                        $scope.info.selectInfo.status = "ADD";
                        $scope.info.selectInfo.isRelate = "red";
                    }
                }
                $rootScope.toasterSuccessInfo("拉取分支成功！");
                $scope.info.diagramScope.updateNode(true, "relate");
            } else {
                $rootScope.toasterErrorInfo(result.desc);
            }
        })
    }
    
    // 重置
    $scope.relive = function(info) {
        if(!$scope.info.selectInfo.id) {
            $rootScope.toasterErrorInfo("id不能为空！");
            return false;
        }
        var url = matrix_product_url + "/feature/dissociateRelation?reqId="+ $stateParams.reqId +"&featureId="+ $scope.info.selectInfo.id;
        $http.get(url).success(function(result) {
            if(result.code == "0") {
                var relateItemArray = angular.copy($scope.info.relateItemList);
                lodash.remove(relateItemArray, {id: $scope.info.selectInfo.id});
                $scope.info.relateItemList = relateItemArray;
                $rootScope.toasterSuccessInfo("重置成功！");
                $scope.info.diagramScope.updateNode(true);
            } else {
                $rootScope.toasterErrorInfo(result.desc);
            }
        })
    }
    $scope.getFeatureSysSimple = function (sys) {
        if("SELLERPORTAL" == sys){
            return "OPC"
        }else{
            return sys;
        }
    }
}]);

app.controller("addMapMenuCtrl", ["$scope", "$rootScope", "$modalInstance", "$http", 'status', 'isFlowTree', 'menu', 'type', function ($scope, $rootScope, $modalInstance, $http, status, isFlowTree, menu, type) {
    $scope.isFlowTree = isFlowTree;
    $scope.menu = {
        name: type == 'add' ? "" : menu.name,
        menuStatus: status,
        status: status,
        parent: status ? menu.id : menu.parent_id,
        path: "",
    };

    $scope.createClick = function () {
        if (isFlowTree) {
            delete $scope.menu.path;
        } else {
            if (!status) {
                $scope.menu.path = menu.menu_data.path;
            }
        }
        $modalInstance.close($scope.menu);
    };

    $scope.cancelClick = function () {
        $modalInstance.dismiss("cancel");
    };
}]);

app.controller("addMapPageModalCtrl", ["$scope", "$rootScope", "$modalInstance", "$http", "branch", "status", function ($scope, $rootScope, $modalInstance, $http, branch, status) {
    $scope.page = {
        name: status ? "" : branch.name,
        pageStatus: status,
        status: status,
        pageMenuId: status ? branch.id : branch.parent_id,
        routeId: status ? branch.menu_data.routeId : branch.menuPath,
        fileName: status ? "" : branch.fileName
    };

    $scope.createClick = function () {
        $modalInstance.close($scope.page);
    };

    $scope.cancelClick = function () {
        $modalInstance.dismiss("cancel");
    };
}]);

app.controller("addFeatureMapCtrl", ["$scope", "$rootScope", "$modalInstance", "$http", "branch", "status", function ($scope, $rootScope, $modalInstance, $http, branch, status) {
    $scope.info = {}
    $scope.info.radioStatus = status ? "true" : "false";
    $scope.info.Radios = true;
    $scope.info.featureTypeList = config_feature_details_type;
    $scope.info.sltFeatureItem = "";
    $scope.feature = {
        name: status ? "" : branch.name,
        status: status,
        pageId: status ? branch.id : branch.parent_id,
        originalPageId: status ? branch.id : branch.parent_id,
        path: status ? branch.menuPath + "/" + branch.title : branch.path
    };

    $scope.selectFeatureType = function(item) {
        $scope.feature.featureKind = item.key;
    }

    //点击新增按钮
    $scope.createClick = function () {
        if(!$scope.feature.featureKind) {
            $rootScope.toasterWarningInfo("类型不能为空！");
            return false;
        }
        if(!$scope.feature.name) {
            $rootScope.toasterWarningInfo("名称不能为空！");
            return false;
        }
        $modalInstance.close($scope.feature);
    };

    //点击取消按钮
    $scope.cancelClick = function () {
        $modalInstance.dismiss("cancel");
    };
}]);